home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- *
- * rendir.c
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <jstring.h>
- #include <dos.h>
-
- void rendir(int count,char **value)
- {
- struct find_t filedata;
- char buf1[80],buf2[80];
- int ret;
-
- if (count != 2) {
- printf("USAGE: rendir oldpath newpath(newname)\n");
- exit (0);
- }
- strncpy(buf1, value[0], 80);
- strncpy(buf2, value[1], 80);
- if (_dos_findfirst(buf1, _A_SUBDIR|_A_NORMAL|_A_RDONLY|_A_ARCH,
- &filedata) != 0) {
- printf("pathが存在しません。\n");
- exit (0);
- }
- if ((jstrchr(buf2, '\\') == NULL) && (jstrchr(buf1, '\\') != NULL)) {
- strncpy(buf2, buf1, 80);
- strcpy(jstrchr(buf2, '\\')+1, value[1]);
- }
- else if ((jstrchr(buf2, ':') == NULL) && (jstrchr(buf1, ':') != NULL)) {
- strncpy(buf2, buf1,2);
- strcpy(buf2+3, value[1]);
- }
- printf("'%s' to '%s'", buf1, buf2);
-
- ret = rename(buf1, buf2); /* ココが本体 */
-
- if (ret == 0) {
- printf(" done.\n");
- }
- else {
- printf(" failed.\n");
- }
- }
-
- void init(char *name)
- {
- fprintf(stderr, "%s copyright (c) 1992 T.Nakatani\n", name);
- }
-
- void main(int argc,char **argv)
- {
- init(argv[0]);
- rendir(argc-1, &argv[1]);
- }
-